<?php

class OOWP_Atom_PostMeta
    extends OOWP_Formattable
{

    public function __construct(array $args = array( ))
    {
        $input = array_merge(array(
            'formatting' => '%s',
            'meta' => null,
            'type' => null,
        ), $args);

        parent::__construct($input);
    }

    protected function getFormatting( )
    {
        return $this->dict['formatting'];
    }

    protected function setFormatting($format)
    {
        $this->dict['formatting'] = $format;
    }

    protected function getMeta( )
    {
        return $this->dict['meta'];
    }

    protected function setMeta($meta)
    {
        $this->dict['meta'] = $meta;
    }

    protected function getType( )
    {
        return $this->dict['type'];
    }

    protected function setType($type)
    {
        $this->dict['type'] = $type;
    }

    protected function getFormatPieces( )
    {
        $post = $this->governor->post;
        $meta = get_post_meta($post->ID, $this->meta, true);
        if (!is_null($this->type)) {
            $meta = date($this->type, strtotime($meta));
        }
        return array(
            sprintf($this->formatting, $meta),
        );
    }

}
